package com.zrspring.libv2.fresco;

import android.net.Uri;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.backends.pipeline.PipelineDraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.common.ResizeOptions;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;

/**
 * Version: 1.0
 * Author: rui
 * CreatDate: 2016年05月15日21:24 24
 * Encoding:UTF-8
 * Description:
 */
public class PipelineDraweeControllerHelper {

    /**
     * @MethodthName: getController
     * @Description:
     * @params: [localPicPath, oldController]
     * @Return:com.facebook.drawee.backends.pipeline.PipelineDraweeController
     * @Throw:
     */
    public static PipelineDraweeController getController(String localPicPath, SimpleDraweeView sdPreview, ResizeOptions options) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(localPicPath))
                .setProgressiveRenderingEnabled(true)
                .setResizeOptions(options)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setOldController(sdPreview.getController())
                .setImageRequest(request)
                .build();
        return controller;
    }


}
